#ifndef __NV_MAIN
#define __NV_MAIN

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ComCtrls.hpp>
#include <Dialogs.hpp>
#include <ImgList.hpp>
#include <Menus.hpp>
#include <ExtCtrls.hpp>

#include "bklist.h"
#include "hcomps.h"
#include "hwindow.h"
#include "HExcept.h"
#include "BkList.h"
#include "HWindow.h"
#include "HCFGStorage.h"
#include "TB97Ctls.hpp"
#include "HMenus.h"
#include "XPMenu.hpp"

#include "int.h"

class TMainForm : public TForm {
__published:	// IDE-managed Components
        TOpenDialog *open;
        THeaderControl *header;
        HBkList *list;
        TImageList *ImageList1;
        TPopupMenu *ppSiteList;
        TMenuItem *mnuFilter;
        TMenuItem *Bysite1;
        TMenuItem *Host1;
        TMenuItem *Date1;
        HExceptionDialog *HExceptionDialog1;
        HCfgStorage *cfg;
        TPanel *panTop;
        TLabel *Label8;
        TLabel *Label9;
        TLabel *txtFilterItem;
        TComboBox *cbGroup;
        TComboBox *cbItem;
        TComboBox *cbCollapse;
        TXPMenu *XPMenu1;
        HMainMenu *HMainMenu1;
        TMenuItem *N3;
        TMenuItem *mnuLoad;
        TMenuItem *N4;
        TMenuItem *Clearlist1;
        TMenuItem *N5;
        TMenuItem *Configuration1;
        TMenuItem *Editsourcenames1;
        TMenuItem *N6;
        TMenuItem *Showsourcenames1;
        TPanel *panBottom;
        TLabel *Label1;
        TLabel *txtCount;
        TLabel *txtFiltered;
        TLabel *Label4;
        TLabel *Label5;
        TLabel *Label2;
        TLabel *Label3;
        TLabel *Label6;
        TLabel *Label11;
        TLabel *txtSize;
        TLabel *Label13;
        TMemo *edtSite;
        TMemo *edtHost;
        TEdit *edtSize;
        TEdit *edtFullUrl;
        TLabel *Label7;
        TEdit *edtTime;
        TSaveDialog *save;
        TMenuItem *S1;
        TMenuItem *M1;
        TMenuItem *D1;
        TMenuItem *D2;
        TMenuItem *N1;
        TSplitter *Splitter1;
        TMemo *edtUrl;
        void __fastcall cbGroupChange(TObject *Sender);
        void __fastcall cbItemChange(TObject *Sender);
        void __fastcall headerSectionClick(
          THeaderControl *HeaderControl, THeaderSection *Section);
        bool __fastcall listDrawItemSection(TObject *Sender, TCanvas *dc,
          int Index, THeaderSection *Section, const MyRect &Rect,
          const TOwnerDrawState &State);
        void __fastcall idClear(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall cbItemDrawItem(TWinControl *Control, int Index,
          TRect &Rect, TOwnerDrawState State);
        void __fastcall cbCollapseChange(TObject *Sender);
        void __fastcall ppSiteListPopup(TObject *Sender);
        void __fastcall idSetFilter(TObject *Sender);
        void __fastcall listClick(TObject *Sender);
        void __fastcall idShowNames(TObject *Sender);
        void __fastcall idNamesEdit(TObject *Sender);
        void __fastcall idConfigure(TObject *Sender);
        void __fastcall HMainMenu1MenuItemCheck(TObject *Sender,
          TMenuItem *Item);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall M1Click(TObject *Sender);
        void __fastcall D1Click(TObject *Sender);
        void __fastcall D2Click(TObject *Sender);
        void __fastcall N1Click(TObject *Sender);
  public:
    Names     Sites;
    Names     Hosts;
    Names     Dates;
    Names     NullNames;
    NameArray Aliases;
    InfoArray Items;
    InfoArray FullItems;
    MyValArray<PNames> FilterItems;

    bool      InProcess;

    char      SplitPath[ MAX_PATH_SIZE ];
    int       SplitInterval;
    bool      SplitAskFile;
    FileArray Files;

  private:
   BOOL __fastcall idFillItems( PHBTreeBase tree,int Level );
   void __fastcall idLoad( TObject *Sender );
   bool __fastcall idAddUrlItem( const UrlInfo& p );
   bool __fastcall idSplitFile( const UrlInfo& it );

  private:
    void        Regroup( void );
    void        Resort( void );
    void        SplitFiles( int interval );
    PNames      CurNames( int num = -1 );   //Use cbGroup->ItemIndex by default

  public:
    __fastcall TMainForm(TComponent* Owner);

  //Vars
     DEF_PROP_P( PInfoArray, CurItems,    { return isCollapsed ? (&Items) : (&FullItems); } )
     DEF_PROP_P( bool,       isCollapsed, { return Group && GroupItem || Collapse; } )
  //Props
    DEF_PROP_VP( tpGroups,   Collapse,  ; )
    DEF_PROP_VP( tpGroups,   Group,     ; )
    DEF_PROP_VP( int,        GroupItem, ; )
    DEF_PROP_VP( int,        SortMode,  ; )
};

extern TMainForm *MainForm;

#endif
